<?php 
require_once("../include/connect.php");
class settings {

function unread() {
  
  $query = "select id from comment where isactive = 0";
  $totalunreadcomment = mysql_num_rows(mysql_query($query));
  
  $query1 = "select id from events where isactive = 0";
  $totalunreadevent = mysql_num_rows(mysql_query($query1));
  
  echo "<div id=\"toolbarActions\">
            <p>Özet: </p>
            <ul>
              <li><a href=\"#\" class=\"tooltip\"><strong>Yorum (". $totalunreadcomment .")</strong></a></li>
              <li><a href=\"#\" class=\"tooltip\">Etkinlik (". $totalunreadevent .")</a></li>
            </ul>
          </div>";
	}
	
function joblist(){
	$adjacents = 3;
	$query = "select id, name, isdeleted, createdate, updatedate from jobs where isdeleted = 0";
	//$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = mysql_num_rows(mysql_query($query));
	
	$targetpage = "settings.php?content=meslek";
	$limit = 10;
	$page = $_GET['page'];
	if($page) 
		$start = ($page - 1) * $limit;
	else
		$start = 0;
    $sql = "select id, name, isdeleted, createdate, updatedate from jobs where isdeleted = 0 LIMIT $start, $limit";
	$result = mysql_query($sql);
	
	echo "<div id=\"innerContent\">
    <div id=\"listHeader\">
      <p class=\"listInfos\">". $total_pages ." adet Kayit bulundu. </p>
    </div>
    <table cellspacing=\"0\" class=\"listTable\" id=\"postList\">
      <thead>
        <tr>
          <th class=\"first\"><div><a href=\"#\" title=\"id\">id</a><div></th>
          <th><a href=\"#\" title=\"name\">Meslek Adı</a></th>
          <th><a href=\"#\" title=\"createdate\">O. Tarihi</a></th>
          <th><a href=\"#\" title=\"updatedate\">G. Tarihi</a></th>
		  <th class=\"last\"><a href=\"#\" title=\"actions\">Islemler</a></th>
        </tr>
      </thead>
	  <tfoot>
		  <tr>
		  <td colspan=\"5\">
              <div class=\"inner\">
                <div class=\"paginate\">";
	if ($page == 0) $page = 1;					
	$prev = $page - 1;							
	$next = $page + 1;							
	$lastpage = ceil($total_pages/$limit);		
	$lpm1 = $lastpage - 1;						
	
	$pagination = "";
	if($lastpage > 1)
	{	
		//previous button
		if ($page > 1) 
			echo  "<span class=\"prev\"><a href=\"$targetpage&page=$prev\">&lt;&lt; &#246;nceki</a></span>";
		else
			echo  "<span class=\"prev disabled\">&lt;&lt; &#246;nceki</span>";	
		
		//pages	
		if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page)
					echo  "<span class=\"current roundedBordersLite\">$counter</span>";
				else
					echo  "<span class=\"current roundedBordersLite\"><a href=\"$targetpage&page=$counter\">$counter</a></span>";					
			}
		}
		elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some
		{
			//close to beginning; only hide later pages
			if($page < 1 + ($adjacents * 2))		
			{
				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
				{
					if ($counter == $page)
						echo  "<span class=\"current roundedBordersLite\">$counter</span>";
					else
						echo  "<span class=\"current roundedBordersLite\"><a href=\"$targetpage&page=$counter\">$counter</a></span>";					
				}
				echo  "...";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=$lpm1\">&gt;</a></span>";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=$lastpage\">$lastpage</a></span>";		
			}
			//in middle; hide some front and some back
			elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
			{
				echo  "<span class=\"next\"><a href=\"$targetpage&page=1\">1</a></span>";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=2\">2</a></span>";
				echo  "...";
				for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
				{
					if ($counter == $page)
						echo  "<span class=\"current roundedBordersLite\">$counter</span>";
					else
						echo  "<span class=\"current roundedBordersLite\"><a href=\"$targetpage&page=$counter\">$counter</a></span>";					
				}
				echo  "...";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=$lpm1\">$lpm1</a></span>";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=$lastpage\">$lastpage</a></span>";		
			}
			//close to end; only hide early pages
			else
			{
				echo  "<span class=\"next\"><a href=\"$targetpage&page=1\">1</a></span>";
				echo  "<span class=\"next\"><a href=\"$targetpage&page=2\">2</a></span>";
				echo  "...";
				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page)
						echo  "<span class=\"current roundedBordersLite\">$counter</span>";
					else
						echo  "<span class=\"current roundedBordersLite\"><a href=\"$targetpage&page=$counter\">$counter</a></span>";					
				}
			}
		}
		
		//next button
		if ($page < $counter - 1) 
			echo  "<span class=\"next\"><a href=\"$targetpage&page=$next\">ileri »</a></span>";
		else
			echo  "<span class=\"next disabled\">ileri »</span>";
				
	}
	echo  "</div>
		      </div>
          </td>
        </tr>
      </tfoot>\n";
      echo "<tbody>";
        while($row = mysql_fetch_array($result))
		{
		   echo "<tr>";
		   echo "<td><div>".$row["id"]."</div></td>";
		   echo "<td><div>".$row["name"]."</div></td>";
		   echo "<td><div>".$row["createdate"]."</div></td>";
		   echo "<td><div>".$row["updatedate"]."</div></td>";
		   echo "<td><div><a href=\"settings.php?content=mslkdel&id=".$row["id"]."\">Sil</a><a href=\"settings.php?content=mslkgncl&id=".$row["id"]."\">D&uuml;zenle</a></div></td>";
		   echo "</tr>";
		}
		echo "</tbody>
    </table>
  </div>";
	}
	
	
	
/*	function jobdelete($id){
	  $tarih = date("Y-m.d"); 
	  $result = mysql_query("UPDATE jobs SET isdeleted=1,updatedate=". $tarih ."WHERE id= ".$id."");
 
	  if($result)
	  {
		 echo "<div class=\"message message-success\">
		        <h6>Bilgi</h6>
		        <p>Seçtiğiniz kayıt başarı ile silindi...</p>
			    <a href=\"settings.php?content=meslek\" >Geri Git</a>
		       </div>"; //message-success / message-erorr / message-notice
		   //header("Location: http://atikyazilim.com/pera/admin/settings.php?content=meslek");
			
		}
		else
		{
			echo "<div class=\"message message-error\">
		     <h6>Bilgi</h6>
		     <p>Hata OIuştu...</p>
		   </div>";
		   
		}
	}
    }
	
	function jobadd(){
		
	}
	
	function jobedit(){
	
	}
	
	*/
  }
$settings = new settings(); 
?>